/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Ranking.java
 *
 * Created on 19/05/2011, 17:05:14
 */
package pitaqueiro;

import java.lang.Object;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import pitaqueiro.Estabelecimento;

/**
 *
 * @author Lucas
 */
public class Ranking extends javax.swing.JFrame {

    /** Creates new form Ranking */
    public Ranking() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        List<String[]> Itens = new ArrayList<String[]>();
        List<String> linha = new ArrayList<String>();
        ManipulacaoDeArquivo leArq = new ManipulacaoDeArquivo();
        String [] cabesalho = {"Nome", "Avaliação", "Tipo", "Endereço"};
        String matriz[][]=null;
        try{
            leArq.leEstabelecimentos();
            leArq.leOpinioes();
            List<Estabelecimento> listaEstabelecimento = leArq.getListaEstabelecimento();
            matriz = new String[listaEstabelecimento.size()][4];
            leArq.geraRankingRestaurantes();
            for(int i = 0; i < listaEstabelecimento.size();i++){

                matriz[i][0] = leArq.getListaRestaurantePopular().get(i).split(";")[0];
                matriz[i][1] = leArq.getListaRestaurantePopular().get(i).split(";")[leArq.getListaRestaurantePopular().get(i).split(";").length -1]; //UltimoElemento = (leArq.geraRankingRestaurantes().get(i).split(" ").length -1);
                matriz[i][2] = " Tipo "; //listaEstabelecimento.get(i).getTipoComida();
                matriz[i][3] = " Endereco " ;//.get(i).getEndereco();
            }
        }catch (Exception ex){
            ex.getMessage();
        }
        TebelaRanking = new javax.swing.JTable();
        BotaoVoltar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        TebelaRanking.setModel(new javax.swing.table.DefaultTableModel(
            matriz,cabesalho) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(TebelaRanking);

        BotaoVoltar.setText("Voltar");
        BotaoVoltar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotaoVoltarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(BotaoVoltar, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 594, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 383, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE)
                .addComponent(BotaoVoltar)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void BotaoVoltarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotaoVoltarActionPerformed
       new Menu().show();
       this.dispose();
    }//GEN-LAST:event_BotaoVoltarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Ranking().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BotaoVoltar;
    private javax.swing.JTable TebelaRanking;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables
}
